from selenium.webdriver.common.by import By

class LoginPages:
    def __init__(self, driver):
        # 初始化驱动对象
        self.driver = driver

    # 1.进入登录页面, 输入一个不存在的用户名
    def input_username(self, username):
        self.driver.find_element(By.ID, "username").send_keys(username)

    # 2.输入密码
    def input_password(self, password):
        self.driver.find_element(By.ID, "password").send_keys(password)

    # 3.输入验证码
    def input_verify_code(self, code):
        self.driver.find_element(By.ID, "verify_code").send_keys(code)

    # 4.点击登录按钮
    def click_login_btn(self):
        self.driver.find_element(By.CLASS_NAME, "J-login-submit").click()

    # 5.获取错误提示信息
    def get_msg(self):
        return self.driver.find_element(By.CLASS_NAME, "layui-layer-content").text